package com.example.project.controller;

import com.example.project.entity.Admin;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author Lenovo
 * @version 1.0
 * @date 2025/4/29 8:21
 * @className AdminController
 */
@Controller
@RequestMapping("/admin")
public class AdminController {
    @GetMapping("")  //  /admin
    public String admin(HttpSession session) {
        Object loginUser = session.getAttribute("loginUser");
        if(loginUser instanceof Admin && ((Admin) loginUser).getAccount().equals("admin")){
            return "admin";
        }
        return "redirect:/";
    }

}
